package com.sunchen.asc.service.item.domain;

import com.sunchen.asc.service.item.vo.TitleVo;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;

@Entity
@Table
@GenericGenerator(name="snowFlow",strategy = "com.sunchen.asc.service.data.SnowflowID")
@Data
/**
 * 主题信息
 */
public class Title {
    @Id
    @GeneratedValue(generator = "snowFlow")
    private Long id;
    //编码
    private String code;
    //名称
    private String name;
    //标志
    private String icon;
    //权力类型
    private String type;
    //机构编码
    private String orgCode;
    //区划编码
    private String regionCode;
    //区划名称
    private String regionName;
    //父级主题编码
    private Long parentId;
    //主题排序
    private Long sortOrder;
    //备注
    private String remark;
    //状态[0 无效 1 有效，默认 1]
    private int status;
    //主题分类
    private String classType;
    //主题类型（1：个人，2：法人）
    private String titleType;
    //是否常用（1：是，2：否）
    private int common;

    @CreationTimestamp
    private Timestamp createTime;
    private String createUser;
    private Timestamp deleteTime;
    private String deleteUser;
    @UpdateTimestamp
    private Timestamp updateTime;
    private String updateUser;

    public Title() {
    }

    public Title(TitleVo titleVo){
        this.id = titleVo.getId();
        this.name = titleVo.getName();
        this.icon = titleVo.getIcon();
        this.type = titleVo.getType();
        this.orgCode = titleVo.getOrgCode();
        this.regionCode = titleVo.getRegionCode();
        this.regionName = titleVo.getRegionName();
        this.parentId = titleVo.getParentId();
        this.remark = titleVo.getRemark();
        this.classType = titleVo.getClassType();
        this.sortOrder = 0L;
        this.titleType = titleVo.getTitleType();
        this.common = titleVo.getCommon();
    }
}
